<?php
/**
 * @Created on 2020/01/15
 * @Author QQ 1026269609@qq.com
*/
namespace app\admin\controller;
use think\Controller;
use think\Db;

class Loginlog extends Base
{
    public function index(){
    	$username=request()->param('username');
    	//开始日
	    $start=request()->param('start');
	    if(empty($start)){
	    	$starts='2019-05-10';
	    }else{
	    	$starts=$start;
	    }
	    //截止日
	    $end=request()->param('end');
	    if(empty($end)){
	    	$ends=date("Y-m-d",strtotime('+1 day'));
	    }else{
	    	$ends=$end;
	    }
		$data=db('member_login_log')->where('username','like',"%{$username}%")->where('login_time','between time',["{$starts}","{$ends}"])->order('id desc')->paginate(10,false,['query'=>request()->param()]);
		$this->assign('data',$data);
		$this->assign('username',$username);
		$this->assign('start',$start);
		$this->assign('end',$end);
        return $this->fetch();
    }
    public function emptylog(){
    	$true=db('member_login_log')->where('1=1')->delete();
    	if($true){
			return json(['status'=>1,'message'=>'清空成功']);
		}else{
			return json(['status'=>0,'message'=>'清空失败']);
		}
    }
}